<!--
 * @Author: zhangxiangsheng 1026583651@qq.com
 * @Date: 2024-06-17 15:04:34
 * @LastEditors: zhangxiangsheng 1026583651@qq.com
 * @LastEditTime: 2024-06-21 16:21:48
 * @FilePath: \appGly\components\formz\components\formselect.vue
 * @Description: 
 * 
 * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. 
-->
<template>
  <view class="">
    <u-form-item
      :label="item.label"
      borderBottom
      ref="item1"
      :prop="item.value"
    >
      <view @click="selectshow" style="flex: 1">{{ inputValue }}</view>
    </u-form-item>
    <u-action-sheet
      :actions="list"
      :show="show"
      @select="select"
      @close="show = false"
    ></u-action-sheet>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        // inputValue: "",
        show: false,
      };
    },
    computed: {
      list() {
        let list = this.item.option.map((e) => {
          return {
            ...e,
            name: this.$z.$t(e.label),
          };
        });
        return list;
      },
      inputValue() {
        return (
          this.list.find((e) => e.value == this.value || e.prop == this.value)
            ?.name || this.$z.$t("请选择")
        );
      },
    },
    props: {
      item: {
        typeof: Object,
        default: () => {
          return {};
        },
      },
      data: {
        typeof: Object,
        default: () => {
          return {};
        },
      },
      value: {
        typeof: [String, Number, Boolean, Array, Object],
        default: () => {
          return "";
        },
      },
    },

    methods: {
      blur() {
        this.$emit("input", this.inputValue);
      },
      select(e) {
        this.$emit("input", e.value || e.prop);
        this.show = false;
        console.log(e, "111");
      },
      selectshow() {
        console.log(this.item);
        if (this.item?.attrs?.disabled) {
          return;
        }
        this.show = true;
      },
    },
  };
</script>

<style></style>
